﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chinaer.Bll
{
    public class ExceptionRepository
    {
        public static void AddException(Exception ex)
        {
            IBll.IException exception = new Bll.ExceptionBLL();
            DTO.ExceptionDTO exceptionDTO = new DTO.ExceptionDTO();

            exceptionDTO.CreateTime = DateTime.Now;
            exceptionDTO.Data = ex.Data;
            exceptionDTO.HelpLink = ex.HelpLink;
            exceptionDTO.ID = Chinaer.Core.Helper.GenerateIDHelper.GenerateID();
            exceptionDTO.InnerException = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex.InnerException);
            exceptionDTO.IsDelete = false;
            exceptionDTO.IsUse = true;
            exceptionDTO.Message = ex.Message;
            exceptionDTO.ModifyTime = DateTime.Now;
            exceptionDTO.Source = ex.Source;
            exceptionDTO.StackTrace = ex.StackTrace;
            if (ex.TargetSite != null)
            {
                exceptionDTO.TargetSite = ex.TargetSite.ToString();
            }
            Model.Common.JsonResult jsonResult = exception.Add(exceptionDTO);
        }
    }
}
